<template>
  <div class="card">
    <h3>单一文件上传「进度管控」</h3>
    <section class="upload_box" id="upload4">
      <input
        ref="inputRef"
        type="file"
        class="upload_inp"
        @change="changeFile"
      />
      <div class="upload_button_box">
        <button
          class="upload_button select"
          :class="[loading ? 'loading' : '']"
          @click="selectFile"
        >
          上传文件
        </button>
      </div>
      <ul class="upload_list">
        <li v-for="item in filelist" :key="item.file.name">
          <div class="upload_progress" v-if="item.progressLen">
            <div class="value" :style="{ width: item.progressLen }"></div>
          </div>
        </li>
      </ul>
    </section>
  </div>
</template>
<script setup>
import { useUploadSingle } from "@/hook";
// 封装上传钩子
let { inputRef, filelist, loading, selectFile, changeFile } = useUploadSingle({
  immediate: true,
  isProgress: true,
});
</script>

<style>
.upload_progress {
  display: block !important;
}
</style>
